{{useCss "/app-pages/css/pay.scss"}}
<div class="fcart">
    <!-- 收货人信息,支付方式，商品清单 -->
    <h2 class="ftitle">订单详情</h2>

    <div class="order_detail">
        <h3 class="titleindex">填写并核对订单信息{{aa}}</h3>

        <div class="item">
            <h4 class="title2">收货信息：</h4>
            <div class="info">
                <div class="addr">
                    <div class="useaddr">
                        {{#if $Cache.pay.pay_ach.info.user_address}}
                        <h5>当前选择的收货地址：</h5>
                        <span>
                            {{$Cache.pay.pay_ach.info.user_address.name}}， {{$Cache.pay.pay_ach.info.user_address.mobilenumber}}， {{$Cache.pay.pay_ach.info.user_address.province}} {{$Cache.pay.pay_ach.info.user_address.town}} {{$Cache.pay.pay_ach.info.user_address.county}}， {{$Cache.pay.pay_ach.info.user_address.detail}}
                        </span>
                        {{#else}}
                        <center><h5><i>请选择收获地址</h5></i></center>
                        {{/if}}
                    </div>
                </div>
                {{#if $Cache.pay.pay_ach.info.state==$Top.config.ACH_STATE.未确认}}
                {{#each $Cache.pay.user_address_list}}
                <div class="addr">
                    <label style="cursor: pointer;">
                        <input type="radio" name="addr" bind-checked="{{$Top.$Cache.pay.pay_ach.info.user_address._id}}" value="{{_id}}" event-click="{{'$Top.$Event.pay.change_user_address'}}" />
                        <span>
                            {{name}}，{{mobilenumber}} {{phonenumber&&("/"+phonenumber)}}，{{province}}{{town}}{{county}}，{{detail}}</span>
                    </label>
                </div>
                {{/each}}
                <div class="add_address">
                    <div class="text">
                        <div class="addr">
                            <select class="province" name="province" event-change={{ '$Event.province'}}>
                                <option class="first" value="0">请选择省</option>
                                {{#each city_list}}
                                <option rel="{{region_id}}" value="{{region_name}}">
                                    {{region_name}}
                                </option>
                                {{/each}}
                            </select>

                            <select class="city" name="city" disabled event-change={{ '$Event.city'}}>
                                <option class="first" value="0">请选择市</option>
                            </select>

                            <select class="county" name="area" disabled>
                                <option class="first" value="0">请选择地区</option>
                            </select>

                            <input type="text" class="detailed_addre" title="详细地址" name="detailed_addre" placeholder="详细地址" maxlength="25" />
                        </div>

                        <div class="connect">
                            <input type="text" name="name" class="name" placeholder="收货人" title="收货人" maxlength="12" />
                            <input type="text" name="mobile_num" class="mobile_num" title="联系手机" placeholder="联系手机" maxlength="11" />
                            <input type="text" name="phone_num" title="座机号码" class="phone_num" placeholder="座机号码" maxlength="11" />
                        </div>
                    </div>

                    <div class="btn">
                        <button event-click="{{'$Event.pay.add_user_address'}}">添加地址</button>
                    </div>
                </div>
                {{/if}}
            </div>
        </div>

        <div class="item hr">

            <h4 class="title2">支付方式： {{#MapValue $Cache.pay.pay_ach.info.pay_method, config.PAY_METHOD}}<!-- {{#if $Cache.pay.pay_ach.info.pay_method==config.PAY_METHOD.担保交易}} 使用支付宝的快捷支付 {{/if}} {{#if $Cache.pay.pay_ach.info.pay_method==config.PAY_METHOD.货到付款}} 货到付款 {{/if}} {{#if $Cache.pay.pay_ach.info.pay_method==config.PAY_METHOD.当面付款}} 当面付款 {{/if}} {{#if $Cache.pay.pay_ach.info.pay_method==config.PAY_METHOD.微信支付}} 微信支付 {{/if}} -->
            </h4>
            {{#if $Cache.pay.pay_ach.info.state==$Top.config.ACH_STATE.未确认}}
            <div class="info">
                <xmp type="tag" name="tagong-paytype">
                    <div class="pay-type">
                        <input bind-checked="{{$Cache.pay.pay_ach.info.pay_method}}" type="radio" bind-input="{{'$Cache.pay.pay_ach.info.pay_method'}}" name="pay-type" event-checked="{{'$Event.pay.change_pay_method'}}" ${__all_attrs__}/>
                        <label style="cursor: pointer;">
                            ${label}<span>${discription}</span>
                        </label>
                    </div>
                </xmp>
                <tagong-paytype
                    value="partner_trade_by_buyer" 
                    bind-disabled="{{!(bus_info.info.alipay.seller_email&&bus_info.info.alipay.key&&bus_info.info.alipay.partner)}}" 
                    discription="使用支付宝的快捷支付"
                    label="支付宝">
                </tagong-paytype>
                <tagong-paytype
                    value="payment_in_cash" 
                    bind-disabled="{{$Cache.pay.pay_ach.info.is_only_online_pay}}"
                    discription="用于大金额订单"
                    label="货到付款">
                </tagong-paytype>
                <tagong-paytype
                    value="face_pay" 
                    bind-disabled="{{$Cache.pay.pay_ach.info.is_only_online_pay}}"
                    discription="最便捷的消费方式"
                    label="当面付款">
                </tagong-paytype>
                <tagong-paytype
                    value="weixin_pay" 
                    discription="使用微信扫描支付"
                    label="微信支付">
                </tagong-paytype>
                <!-- <div class="pay-type">
                                <input type="radio" name="pay-type" value="1" />邮局汇款
                                <span>通过快钱平台收款 汇款后1-3个工作日到账</span>
                            </div> -->
            </div>
            {{/if}}
        </div>

        <div class="item hr">
            <h4 class="title2">商品清单</h4>
            <div class="info">
                <table class="paper-table">
                    <thead>
                        <td class="goods_id">商品编号</td>
                        <td class="goods">商品名</td>
                        <td class="price">价格</td>
                        <td class="discount">优惠</td>
                        <td class="count">购买数量</td>
                    </thead>
                    {{#each $Cache.pay.pay_ach.info.goods_info}}
                    <tr>
                        <td class="goods-id">
                            {{goods._id}}
                        </td>
                        <td class="goods-name">
                            <img bind-src="{{goods.preview_img_url}}?imageView/1/w/25/h/25">
                            <a href="/goods_details.html?id={{goods._id}}">{{goods.goods_name}}</a>
                        </td>
                        <td> ￥{{#Fixed goods.price}} </td>
                        <td> ￥{{#Fixed (goods.price - goods.cash)||0}} </td>
                        <td> {{num}} / {{goods.unit}} </td>
                    </tr>
                    {{/each}}
                </table>


                <div class="money">
                    <div class="money-item">
                        <div class="left">商品总金额：</div>
                        <div class="right">￥{{#Fixed $Cache.pay.pay_ach.sou_cash}}</div>
                    </div>
                    <div class="money-item">
                        <div class="left">打折优惠：</div>
                        <div class="right">￥{{#Fixed $Cache.pay.pay_ach.sou_cash-$Cache.pay.pay_ach.cash}}</div>
                    </div>
                    <div class="money-item">
                        <div class="left">推荐返利金额抵消：</div>
                        <div class="right">￥{{#Fixed ($Cache.pay.pay_ach.bind_acc)||0}}</div>
                    </div>
                    <div class="money-item">
                        <div class="left">运费：</div>
                        <div class="right">￥{{#Fixed $Cache.pay.pay_ach.express_cash}}</div>
                    </div>
                    <div class="money-item">
                        <div class="left">应付金额：</div>
                        <div class="right">
                            {{#if $Cache.pay.pay_ach.cus_cash}}
                                <span>
                                <del>￥{{#Fixed $Cache.pay.pay_ach.sou_finally_cash}}</del>
                                改：￥{{#Fixed $Cache.pay.pay_ach.cus_cash}}
                                </span>
                            {{#else}}
                                <span>￥{{#Fixed $Cache.pay.pay_ach.finally_cash}}</span>
                            {{/if}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="item hr">
            <h4 class="title2">优惠码：</h4>
            <div class="coupon">
                {{#if $Cache.pay.pay_ach.coupon_id}} 
                    使用优惠码：{{$Cache.pay.pay_ach.coupon_id}}
                {{#else}}
                    {{#if $Cache.pay.pay_ach.info.state==$Top.config.ACH_STATE.未确认}}
                    <label for="coupon">请输入优惠码：
                        <input type="text" class="android" value="{{$Cache.pay.use_coupon_id}}" bind-input="{{'$Cache.pay.use_coupon_id'}}">
                        <button event-click="{{'$Event.pay_ach.bind_coupon'}}">绑定优惠码</button>
                        <i>绑定优惠码后不能再修改订单</i>
                    </label>
                    {{#else}}
                    <i>该订单没有使用优惠码</i>
                    {{/if}}
                {{/if}}
            </div>
        </div>
        <div class="item hr">
            <h4 class="title2">优惠券：</h4>
            <div class="ticket">
                {{#if $Cache.pay.pay_ach.ticket_id}}
                    使用优惠券：{{$Cache.pay.useing_ticket.ticket_factory.info.name+"（"+$Cache.pay.useing_ticket.uid+"）"}}
                {{#else}}
                    {{#if $Cache.pay.pay_ach.info.state==config.ACH_STATE.未确认}}
                        <android:selectSearch datalist-key="$Cache.pay.ticket_list_for_ach" use-value-as-result="true" value="{{$Cache.pay.use_ticket_id}}" placeholder="请选择优惠券" search-placeholder="模糊查询" bind-input="{{'$Cache.pay.use_ticket_id'}}" event-change="{{'$Event.pay.get_ticket'}}">
                            {{#each $Cache.pay.ticket_list_for_ach}}
                            <optionItem value="{{_id}}" search-data="{{uid+ticket_factory.info.name}}" title="{{ticket_factory.info.intro}}">{{ticket_factory.info.name}}（{{uid}}）</optionItem>
                            {{/each}}
                        </android:selectSearch>
                        <button event-click="{{'$Event.pay.bind_ticket'}}">确定使用优惠券</button>
                        <i>确定使用优惠券后不能再修改</i>
                    {{#else}}
                    <i>该订单没有使用优惠券</i>
                    {{/if}}
                {{/if}}
            </div>
        </div>
        <div class="item hr">
            <h4 class="title2">返利抵扣：</h4>
            <div class="bus_bind">
                {{#if $Cache.pay.pay_ach.bus_user_money}}
                    使用 <b>推荐返利</b> 的抵消金额：￥
                    <span>{{#Fixed $Cache.pay.pay_ach.bus_user_money}}</span>
                {{#else}}
                    {{#if $Cache.pay.bus_user.money > 0}}
                    使用抵扣金额（可用抵扣金额：
                    <span>￥{{#Fixed $Cache.pay.bus_user.money}}</span>）：
                    <inputnumber min="0" max="{{
    window.Math.min($Cache.pay.pay_ach.cus_cash||$Cache.pay.pay_ach.finally_cash , $Cache.pay.bus_user.money)  }}" fixed="2" value="{{$Cache.pay.bus_user_money}}" bind-input="{{'$Cache.pay.bus_user_money'}}"></inputnumber>
                    <button event-click="{{'$Event.pay.use_bus_user_money'}}">确定抵扣金额</button>
                    <i>确定后不能再修改抵扣额度</i>
                    {{#else}}
                    <i>无可用的抵扣金额（来自推荐返利）</i>
                    {{/if}}
                {{/if}}
            </div>
        </div>

        <div class="item hr">
            {{#> "user_ach_controller","$Cache.pay.pay_ach"}}
        </div>
        <android:dialogwindow show="{{submitOrder}}" width="450px">
            <android:dialogwindow:contents>
                <div>
                    <center>
                        <h3>您的订单已提交</h3>
                        <p><i>此对话框将在 {{init_time||'15'}} 秒后关闭</i></p>
                    </center>
                    <p><b>订单号：</b>{{$Cache.pay.pay_ach._id}}</p>
                    <p><b>收件人：</b>{{$Cache.pay.pay_ach.info.user_address.name}}</p>
                    <p><b>联系方式：</b>{{$Cache.pay.pay_ach.info.user_address.mobilenumber||$Cache.pay.pay_ach.info.user_address.phonenumber}}</p>
                    <p><b>收货地址：</b>{{$Cache.pay.pay_ach.info.user_address.province}} {{$Cache.pay.pay_ach.info.user_address.town}} {{$Cache.pay.pay_ach.info.user_address.county}}， {{$Cache.pay.pay_ach.info.user_address.detail}}</p>
                </div>
            </android:dialogwindow:contents>
            <android:dialogwindow:actions>
                <android:dialogwindow:action>
                    <href to="/main.html"><android:paperbutton event-click="{{'$Event.pay.close_submit_order'}}">继续购物</android:paperbutton></href>
                </android:dialogwindow:action>
                <android:dialogwindow:action>
                    <href to="/user/orders.html"><android:paperbutton event-click="{{'$Event.pay.close_submit_order'}}">查看订单列表</android:paperbutton></href>
                </android:dialogwindow:action>
            </android:dialogwindow:actions>
        </android:dialogwindow>
    </div>
</div>
